From: Eric Sandeen Date: Tue, 6 Jul 2021 17:56:03 +0000 (+0200) Subject: [PATCH] seq_file: Disallow extremely large seq buffer allocations X-Git-Tag: archive/raspbian/5.10.46-5+rpi1^2~44 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/%22bookmarks:/?a=commitdiff_plain;h=70cfb8f7762b9e40341583009e49c2b728eea254;p=linux.git [PATCH] seq_file: Disallow extremely large seq buffer allocations There is no reasonable need for a buffer larger than this, and it avoids int overflow pitfalls. Fixes: 058504edd026 ("fs/seq_file: fallback to vmalloc allocation") Reported-by: Qualys Security Advisory Suggested-by: Al Viro Signed-off-by: Eric Sandeen Gbp-Pq: Topic bugfix/all Gbp-Pq: Name seq_file-Disallow-extremely-large-seq-buffer-allocat.patch --- diff --git a/fs/seq_file.c b/fs/seq_file.c index 03a369ccd28..472714716be 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -32,6 +32,9 @@ static void seq_set_overflow(struct seq_file *m) static void *seq_buf_alloc(unsigned long size) { + if (unlikely(size > MAX_RW_COUNT)) + return NULL; + return kvmalloc(size, GFP_KERNEL_ACCOUNT); }